package com.huanletao.proxy.cglib;

/**
 * <p>
 * </p>
 * package: com.huanletao.proxy.cglib
 * description:
 * className: Demo1
 * author:  踏雪无痕
 * copyright: Copyright (c) 2022/8/26 22:58
 * since: 1.0.0
 */
public class Demo1 {

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

//        MethodNameAdvisor advisor = new MethodNameAdvisor(new Logger());
//        advisor.setMethodNamePrefix("w");
//        LoginService loginService = ProxyCreator.createCglibProxy(advisor, LoginServiceImpl.class);

        AnnotationMethodNameAdvisor advisor1 = new AnnotationMethodNameAdvisor(new Logger());
        advisor1.setAnnotationType(Log.class);

        LoginService loginService = ProxyCreator.createCglibProxy(advisor1, LoginServiceImpl.class);

        loginService.sayhello();


    }
}

interface LoginService {

    default void sayhello() {
        System.out.println("============登录用户===========");
        System.out.println("sfsdfesfsdfsdrewrrsfasdfasdfsdfsd");
    }

    default void say(String username, String password) {
        System.out.println("say hello");
    }

    default void wsay() {
        System.out.println("wsay hello");
    }
}

@Log
class LoginServiceImpl implements LoginService {
    @Override
    public void sayhello() {
        LoginService.super.sayhello();
    }

    @Override
    public void say(String username, String password) {
        LoginService.super.say(username, password);
    }

    @Override
   // @Log
    public void wsay() {
        LoginService.super.wsay();
    }
}
